#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include<queue>
using namespace std;
int f(int a, int b)
{
	int x;
	if (a < b)
	{
		x = a;
		a = b;
		b = x;
	}
	while (a % b)
	{
		x = a % b;
		a = b;
		b = x;
	}
	return b;
}
int main()
{
	int a, b,x,k=0;
	cin >> a >> b;
	x = a * b;
	for (int i = a; i <= b; i = i + a)
	{
		int s = x / i;
		if (s*i==x&&f(i, s) == a)
		{
			k++;
			//cout << i << endl;
		}
	}
	cout << k << endl;
	return 0;
}